﻿#ifndef PatternManageWidget_H
#define PatternManageWidget_H

#include <QWidget>
#include <QDir>

#ifdef Q_OS_WIN
#include <windef.h>
#include <winbase.h>
#endif

#include "setcontrolstyle.h"
#include "mybutton.h"
#include "items/fileitem.h"
#include "promptdialog.h"
#include "wordsinputdialog.h"
//#include "Include/datafiledst.h"
#include "datafile/datafiledst.h"
#include "datafile/datafiledsr.h"
#include "datafile/datafilequi.h"
#include "datafile/datafilequix.h"
#include "datafile/hpgl/importhpgl.h"
#include <QMouseEvent>
#include <QDateTime>
#include "mctype/mainwidgetfunction.h"
 

namespace Ui {
class PatternManageWidget;
}

class PatternManageWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PatternManageWidget(QWidget *parent = 0);
    ~PatternManageWidget();
    enum MANAGE_MODE {MANAGE_IMPORT = 0, MANAGE_EXPORT, MANAGE_DELETE,MANAGE_IMPORT_EXEC,MANAGE_EXPORT_EXEC};

private:
    Ui::PatternManageWidget *ui;
    int m_itemPerPage;//界面每页条目数
    QList<MyButton*> m_itemBtnList;

private:
    QList<FileItem> m_fileItemList;//文件列表
    QList<QString> m_selectFileItemList;//选中文件列表
    QList<QString> m_cpSelectFileItemList;//选中文件列表

    int m_curPages;//当前页
    int m_pageNums;//总页数
    QString m_usbPath;//优盘路径
    QString m_rootPath;//操作屏根路径
    QString m_curPath;//当前路径
    int m_selectAll;//1:全选   -1:全不选
    MANAGE_MODE m_manageMode;//导入、导出、删除

    QSize m_imgSize;

private:
    void initialize();//初始化
    void initControl();//初始化窗体控件，包括位置、尺寸、样式
    void initResolution();
    void initControlStyle();//初始化窗体控件样式

public:
    void setTypeLogo(QString tStyle);//设置类型图标
    void setMainTitle(QString str);//设置主title
    void setSubTitle(QString str);//设置副title

private:
    void initDirPath(QString path);//初始化目录中的目录和文件
    void initExecDirPath(QString path);//初始化目录中的目录

    void refreshUi();//刷新界面显示
    QString detectUsb();//检测优盘是否存在
    void refreshCheckedPage();//刷新条目选中状态
    void clickItem(int idx);//点击某一条目
    void patternImportOrExport(QString mainStr,QString subStr,QString path);//花样导入或导出
    void patternDelete();//花样删除
    void clearFileInfo();

public:
    void patternManage(MANAGE_MODE mode);//花样导入
    void setImportImageSize(QSize imgSize); //设置导入花样时生成预览图片的图片大小(与花样选择界面的图片大小相同)

signals:
    void siDeletePattern();//删除了文件的信号
    void siReplacePattrn(QString path);//替换了文件的信号

private slots:
    void on_button1_clicked();
    void on_button2_clicked();
    void on_button3_clicked();
    void on_button4_clicked();
    void on_button5_clicked();
    void on_button6_clicked();
    void on_button7_clicked();
    void on_button8_clicked();
    void on_button9_clicked();
    void on_button10_clicked();
    void on_button11_clicked();
    void on_button12_clicked();
    void on_button13_clicked();
    void on_button14_clicked();
    void on_button15_clicked();
    void on_button16_clicked();
    void on_button17_clicked();
    void on_button18_clicked();
    void on_button19_clicked();
    void on_button20_clicked();
    void on_button21_clicked();
    void on_button22_clicked();
    void on_buttonPgUp_clicked();
    void on_buttonPgDn_clicked();
    void on_buttonOk_clicked();
    void on_buttonCancel_clicked();
    void on_buttonBackUpDir_clicked();
    void on_buttonSelectAll_clicked();
    void on_buttonNewFolder_clicked();

 //鼠标事件
protected:
    void mousePressEvent(QMouseEvent *e);
    void mouseReleaseEvent(QMouseEvent *e);

private:
    int m_mousePressX;
    int m_mousePressY;
    int m_mouseReleaseX;
    int m_mouseReleaseY;
};

#endif // PatternManageWidget_H
